//
//  FSVisitorView.swift
//  fushp_weibo
//
//  Created by fushp on 2017/11/23.
//  Copyright © 2017年 fushp. All rights reserved.
//

import UIKit
//访客视图
class FSVisitorView: UIView {
    var imageview:UIImageView?
    
    var visitorInfo: [String: String]?{
        didSet {
            guard let image = visitorInfo?["image"] else {
                return
            }
            //首页动画旋转
            if image == "" {
                startAminal()
                return
            }
            imageview?.isHidden = true
            print("\(String(describing: visitorInfo?["message"]))")
            
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setui()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
   
}

extension FSVisitorView {
    func setui(){
        backgroundColor = UIColor.clear
        imageview = UIImageView(frame: CGRect(x:0 ,y:300, width: 100,height:100) )
        self.addSubview(imageview!)
        imageview?.image = UIImage(named: "visitordiscover_feed_image_smallicon")
        
    }
    private func startAminal() {
        let aminal = CABasicAnimation(keyPath: "transform.rotation")
        aminal.toValue = CGFloat.pi * 2
        aminal.repeatCount = MAXFLOAT
        aminal.duration = 15
        aminal.isRemovedOnCompletion = false
        imageview?.layer.add(aminal, forKey: nil)
        
    }
}
